<?php
//==================================
//设置搜索条件，创造url
//拼装sql语句
//需要剔除页码，剔除
//$_url=$_SERVER["QUERY_STRING"];

if($_REQUEST['now_page'])
{
    $_full_url=$_SERVER["QUERY_STRING"]."&now_page=".$_REQUEST['now_page'];
}
else
{
    $_full_url=$_SERVER["QUERY_STRING"];
}


$_url_list=explode("&",$_full_url);



if(!empty(array_filter($_url_list)))
{

//循环所有的参数
foreach ($_url_list as $k=>$v)
{

    //把参数分成key和值，看有没有重复的参数
    $_parama_list=explode("=",$v);
    if($_parama_list[0] != 'sort'){
        $_new_url_list[$_parama_list[0]]=$_parama_list[1];

    }

}


//把数组调整格式，便于下面转换回字符串
foreach ($_new_url_list as $k=>$v)
{
    if($v){
        $_new_url_list_2[]=$k."=".$v;
    }
}



$data['url_parameter'] =implode("&",$_new_url_list_2);
$url_parameter =implode("&",$_new_url_list_2);
}
//echo $data['url_parameter'];
//echo $url_parameter;


if(!$url_parameter)
{
    $url_parameter="&set=all";
}

if(!$data['url_parameter'])
{
    $data['url_parameter']="set=all";
}


/*$url_parameter = $_SERVER["QUERY_STRING"].$url_parameter;

$s_url_list=explode("&",$url_parameter);


foreach($s_url_list as $s_key=>$s_url){
    $s_url_arr = explode('=',$s_url);

    if($s_url_arr[0] == 'sort'){
        unset($s_url_list[$s_key]);
    }
}
*/
if(!isset($_REQUEST['sort'] )){
    $_REQUEST['sort'] = 'grid';
}
?>